<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Single Class Source</title>
</head>
<body>
  <pre class="brush: java">
//Package declaration and imports ommited for brevity
@Entity
@Table(name="basic_person")
public class Person {
	private int id;
	private String firstName;
	private String lastName;
	private String fullName;
	private Gender gender;
	private Date birthDate;
	private String title;
	private Date createdTimestamp;
	
	@Id @GeneratedValue
	public int getId() {
		return id;
	}

	private void setId(int id) {
		this.id = id;
	}

	@Column(nullable = false, length = 30)
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	@Column(nullable = false, length = 30)
	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Transient
	public String getFullName() {
		return getFirstName() + " " + getLastName();
	}
	
	@Enumerated(EnumType.STRING)
	@Column(nullable = false, length = 6, name = "gender")
	public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	@Temporal(TemporalType.DATE)
	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	private void setCreatedTimestamp(Date createdTimestamp) {
		this.createdTimestamp = createdTimestamp;
	}

	@org.hibernate.annotations.Generated(
			org.hibernate.annotations.GenerationTime.ALWAYS)
	@Column(insertable = false, updatable = false, 
			columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
	public Date getCreatedTimestamp() {
		return createdTimestamp;
	}
	
	@org.hibernate.annotations.Formula(
			value = "IF(gender = 'MALE', 'Mr', 'Ms')")
	public String getTitle() {
		return title;
	}

	private void setTitle(String title) {
		this.title = title;
	}

	@Override
	public String toString() {
		StringBuilder strBuilder = new StringBuilder();
		strBuilder.append("Person id : " + getId()).
			append(", Title : ").append(getTitle()).
			append(", Name : ").append(getFullName()).
			append(", Gender : ").append(getGender()).
			append(", Birth Date : ").append(getBirthDate()).
			append(", created : ").append(getCreatedTimestamp());
		
		return strBuilder.toString();
	}
}
  </pre>    
</body>
</html>
